<template>
	<view class="box">
		<view class="top">
			<u-navbar height="50" back-icon-color="#333" title="我的兑换" title-color="#333" title-size="36"></u-navbar>
		</view>
		<view class="goodsList" v-if="goodsList">
			<view class="goods" v-for="(item,index) in goodsList" :key="item.id">
				<view class="left">
					<image v-if="item.goods_details" :src="item.goods_details.pg_image[0]" mode="widthFix" style="width: 140rpx;"></image>
				</view>
				<view class="right">
					<view class="name">
						{{item.goods_details.pg_name}}
					</view>
					<view class="point">
						{{item.pg_allpoint}}积分
					</view>
					<view class="time">
						{{item.pg_addtime}}
					</view>
				</view>
			</view>
		</view>
		<view class="nodata" v-else>
			<image src="../../static/empty.png" mode="widthFix" style="width: 410rpx;"></image>
		</view>
	</view>
</template>

<script>
	import {
		exchangelist
	} from '@/api/user.js'
	export default {
		data() {
			return {
				goodsList: []
			};
		},
		onLoad() {
			this.initData()
		},
		methods: {
			initData() {
				exchangelist().then(res => {
					console.log("兑换列表", res);
					this.goodsList = res.list
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.nodata{
		width: 410rpx;
		height: 240rpx;
		margin: 200rpx auto;
	}
	.box {
		box-sizing: border-box;
		padding: 1rpx;
		background-color: #f5f5f5;
		width: 750rpx;
		min-height: 100vh;
	}

	.goodsList .goods {
		width: 710rpx;
		box-sizing: border-box;
		padding: 20rpx;
		background-color: #fff;
		margin: 20rpx auto;
		display: flex;
		align-items: center;
		justify-content: space-between;
		border-radius: 20rpx;

		.left {
			width: 140rpx;
			height: 140rpx;
			background: #F2F2F2;
			border-radius: 5rpx;
			overflow: hidden;
		}

		.right {
			width: 500rpx;
			height: 140rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;

			.name,
			.time {
				font-size: 26rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #333333;
			}

			.point {
				font-size: 26rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #787878;

			}

		}

	}
</style>